package com.google.gac.masai.getit;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;

public class PrefsFragment extends PreferenceFragment {
	//initialization for numSpecRules is in MenuArrayAdapter
	
	static PreferenceScreen wrapper;
	static Preference first;
	static Preference second;
	static Preference third;
	
	private SharedPreferences mPreferences;
	
	Context mContext;
	

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        mContext = MainActivity.mContext;
        mPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);

        // Load the preferences from an XML resource
        addPreferencesFromResource(R.xml.settings);
        wrapper = (PreferenceScreen) findPreference("prefscreen");
        first = (Preference) findPreference("first_special");
        second = (Preference) findPreference("second_special");
        third = (Preference) findPreference("third_special");
        
        //Hides the three rules if they don't exist
        boolean firstExists = mPreferences.getBoolean("first_special", false);
        boolean secondExists = mPreferences.getBoolean("second_special", false);
        boolean thirdExists = mPreferences.getBoolean("third_special", false);
        
        if (!firstExists)
        	wrapper.removePreference(first);
        
        if (!secondExists)
        	wrapper.removePreference(second);
        
        if (!thirdExists)
        	wrapper.removePreference(third);
        
    }
    
}
